<template>
  <div>
    <select class="form-control" v-model="worktype" @change="change">
      <option v-for="option in this.worktypes" v-bind:value="option.id">{{ option.name }}</option>
    </select>
  </div>
</template>
<script>
export default {
  name: 'WorkType',
  props: ['selectedworktype','withUnlimit'],
  components: {
    // VueResource
  },
  data: function () {
    return {
      worktype: this.selectedworktype,
      worktypes: []
    }
  },
  methods: {
    loaddata: function () {
      if (this.withUnlimit) {
        this.worktypes = [{ id: -1, name: '不限' }]
        this.worktypes = this.worktypes.concat(this.$store.state.sysconfigs.workerType)
      }
      else
        this.worktypes = this.$store.state.sysconfigs.workerType
    },
    change: function(ele){
      this.$emit('worktypechange', this.worktype)
    }
  },
  created: function () {
    this.loaddata()
  }
}
</script>
